package org.nf.shopping.controller;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.nf.shopping.common.vo.ResultVO;
import org.nf.shopping.entity.Son;
import org.nf.shopping.service.SonService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2024-12-12
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/son")
public class SonController extends BaseController{

    private final SonService sonService;

    @GetMapping("/listSon")
    public ResultVO<PageInfo<Son>> listSon(Integer limit, Integer page, String typeName){
        PageInfo<Son> pageInfo = sonService.listSon(limit, page, typeName);
        return success(pageInfo);
    }

    @PostMapping("/updateSon")
    public ResultVO updateSon(Son son){
        sonService.updateSon(son);
        return success();
    }

    @PostMapping("/deloneSon")
    public ResultVO deloneSon(Integer id){
        sonService.deloneSon(id);
        return success();
    }

    @PostMapping("/addSon")
    public ResultVO addSon(Son son){
        sonService.addSon(son);
        return success();
    }

    @PostMapping("/getSonList")
    public ResultVO<List<Son>> getSonList(){
        return success(sonService.getSonList());
    }
}
